<?php

    include("header.php");

    setTabIndex(2);

    createPage("Liga - Zilveren Toren");

    if (isset($_SESSION['user'])) $user = $_SESSION['user'];

?>



<table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0" bgcolor="#FFFFFF">



    <tr>

        <td id="leftFiller" valign="top" height="100%" rowspan="3" bgcolor="#666666">

            <table border="0" cellpadding="0" cellspacing="0" height="100%" width="8px">

                <tr><td>&nbsp;</td></tr>

            </table>

        </td>

        <td id="header" valign="top" width="100%">

            <table border="0" width="100%" cellpadding="3" cellspacing="0" bgcolor="#10425b">
                <tr>
                    <td bgcolor="#666666" width="40%">
                        <?php include("inc_title.html"); ?>
                    </td>
                    <td bgcolor="#666666" align="right" valign="top">&nbsp;
                          <span class="headerSmall">Huidige versie PLAYER.DBF: <?=CURRENT_PLAYER_DBF?>
                        <?php
                        if (isset($user) && $user->club_id == 100) {
                        ?>
                        <br/>
                        <a class="headerSmall" href="import_player.php">laad andere versie</a>
                        <?php
                        }
                        ?>
                        </span>
                    </td>
                </tr>
            </table>
            <table align="center" border="0" width="100%" height="90%" cellpadding="0" cellspacing="0" style="border-top:#BCDD10 4px solid;">
                <tr>
                    <?php include("inc_sublinks.php"); ?> 
                </tr>

                <tr><td colspan="2" nowrap bgcolor="#BCDD10" height="4"><img src="../../assets/images/spacer.gif" alt="" height="1" width="1"></td></tr>

                <tr>

                    <td>&nbsp;</td>

                    <td valign="top">

                        <table align="left" cellspacing="10" width="100%">

                            <tr>

                                <td>

                  <span class="blackHeaderLarge">Zilveren Toren <?=CURRENT_ZT_YEAR?> - Contactinfo</span>

                  <br/>

                    Alle contactinformatie omtrent de deelnemende clubs vindt u hier.

                  Niet ingeschreven clubs zijn grijs gemarkeerd en tonen de (eventuele) info van vorig seizoen.</br>

                  Klik op het clubnummer voor detailinfo (enkel mogelijk voor ingeschreven clubs).

                                  Ploegleiders kunnen hun clubgegevens zelf aanpassen (login rechtsboven).

                </td>

                            </tr>

                            <tr>

                                <td>

                  <table width="90%" align="center" cellspacing="5" class="yellowBox">

                      <tr>

                          <td>&nbsp;</td>

                          <td><strong>Nummer</strong></td>

                          <td><strong>Naam</strong></td>

                          <td><strong>Lokaal</strong></td>

                          <td><strong>Ploegleider</strong></td>

                          <td><strong>Speeldag</strong></td>

                      </tr>

                      <?php

                        mysql_connect(DB_SERVER, DB_USER, DB_PWD);

                        mysql_select_db(DB_CATALOG);

                        $query = "select c.club_id, c.clubname, ci.site, ci.play_day

                          from club c left outer join zt_club_info ci

                          on c.club_id = ci.club_id where c.clubname <> ''";

                        $result = mysql_query($query);

                        $clubItems = array();

                        while ($row = mysql_fetch_assoc($result)) {

                            $result2 = mysql_query("select concat(u.firstname,

                              ' ', u.lastname) as captain from user u join zt_captain c

                              on u.user_id = c.user_id where u.club_id =

                              ".$row['club_id']." order by c.tournament_id desc

                              limit 1");

                            $row2 = mysql_fetch_assoc($result2);

                            $clubItem = new ZTClubInfo;

                            $clubItem->club_id = $row['club_id'];

                            $clubItem->clubname = $row['clubname'];

                            $clubItem->site = $row['site'];

                            $clubItem->play_day = $row['play_day'];

                            $clubItem->contact_name = $row2['captain'];

                            array_push($clubItems, $clubItem);

                        }

                        /*$query = sprintf("select ci.* from zt_club_info ci

                          join zt_subscription s on s.club_id = ci.club_id join

                          zt_tournament t on t.tournament_id = s.tournament_id

                          where t.tournament_name = '%s' order by ci.club_id",

                          CURRENT_ZT_TOURNAMENT);

                        $result = mysql_query($query);

                        $clubItems = array();

                        while ($row = mysql_fetch_assoc($result)) {

                            $result2 = mysql_query("select clubname from club where club_id = ".$row['club_id']);

                            $row2 = mysql_fetch_assoc($result2);

                            $clubItem = new ZTClubInfo;

                            $clubItem->club_id = $row['club_id'];

                            $clubItem->clubname = $row2['clubname'];

                            $clubItem->site = $row['site'];

                            $clubItem->address = $row['address'];

                            $clubItem->city = $row['city'];

                            $clubItem->phone = $row['phone'];

                            $clubItem->play_day = $row['play_day'];

                            $clubItem->contact_name = $row['contact_name'];

                            $clubItem->contact_address = $row['contact_address'];

                            $clubItem->contact_city = $row['contact_city'];

                            $clubItem->contact_phone = $row['contact_phone'];

                            $clubItem->contact_email = $row['contact_email'];

                            array_push($clubItems, $clubItem);

                        }*/



                          $link = "";

                        foreach ($clubItems as $item) {

                          $style="";

                          $query = sprintf("select count(1) as subscribed from zt_subscription s join

                            zt_tournament t on t.tournament_id = s.tournament_id

                            where t.isCurrent = 1 and s.club_id = %u", $item->club_id);

                          $result = mysql_query($query);

                          $row = mysql_fetch_assoc($result);

                          $subscribed = $row['subscribed'];

                          if ($subscribed == 0) {

                            $style="color:#999999";

                          }

                    ?>

                    <tr>

                      <?php

                        if ( isset($user) && $user->club_id == $item->club_id && $subscribed == 1 ) {

                      ?>

                          <td><a href="edit_club_info.php"><img src="../../assets/images/16x16/shadow/document.gif" border="0"></a></td>

                      <?php

                        } else {

                      ?>

                        <td>&nbsp;</td>

                      <?php

                        }



                        if ($subscribed == 1) {

                      ?>

                        <td style="<?=$style?>"><a href="zt_club_info_detail.php?club_id=<?=$item->club_id?>"><?=$item->club_id?></a></td>

                      <?php

                        } else {

                      ?>

                        <td style="<?=$style?>"><?=$item->club_id?></td>

                      <?php

                        }

                      ?>



                            <td style="<?=$style?>"><?=$item->clubname?></td>

                          <td style="<?=$style?>"><?=$item->site?></td>

                        <td style="<?=$style?>"><?=$item->contact_name?></td>

                        <td style="<?=$style?>"><?=strtoupper($item->play_day)?></td>

                      <?php

                          }

                      ?>

                    </tr>

                  </table>

                                </td>

                            </tr>

                        </table>

                    </td>

                </tr>

            </table>

        </td>

    </tr>

</table>



<?php include("footer.php") ?>

